package com.orange.community.dao;

import com.orange.community.entity.LoginTicket;
import org.apache.ibatis.annotations.*;

/**
 * @author GaryGyp
 * @Description 用注解的方式实现 MyBatis
 * @Deprecated: 意思是不推荐使用该类
 */
@Mapper
@Deprecated
public interface LoginTicketMapper {

    // 插入一个凭证，增加一条数据
    @Insert({
            "insert into login_ticket (user_id, ticket, status, expired) ",
            "values(#{userId}, #{ticket}, #{status}, #{expired})"
    })
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insertLoginTicket(LoginTicket loginTicket);

    // 依据凭证查询
    @Select({
            "select id, user_id, ticket, status, expired ",
            "from login_ticket where ticket=#{ticket}"
    })
    LoginTicket selectByTicket(@Param("ticket")String ticket);

    //修改凭证状态
    @Update({
            "update login_ticket set status = #{status} where ticket=#{ticket} "
    })
    int updateStatus(@Param("ticket")String ticket, @Param("status")int status);

}
